package com.example.demo.mapper;

import org.apache.ibatis.annotations.*;
import com.example.demo.domain.BlogPost;
import java.util.List;

@Mapper
public interface BlogPostMapper {

    @Select("SELECT * FROM blog_post")
    List<BlogPost> findAll();

    @Select("SELECT * FROM blog_post WHERE id = #{id}")
    BlogPost findById(Long id);

    @Insert("INSERT INTO blog_post(title, content) VALUES(#{title}, #{content})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(BlogPost blogPost);

    @Update("UPDATE blog_post SET title = #{title}, content = #{content} WHERE id = #{id}")
    void update(BlogPost blogPost);

    @Delete("DELETE FROM blog_post WHERE id = #{id}")
    void delete(Long id);
}
